package ray;

import math.Vecmath;

public class Ray
{
    
    protected double[] rayOrigin;
    //<editor-fold defaultstate="collapsed" desc="getOrigin">
    public double[] getOrigin()
    {
        return this.rayOrigin;
    }
    //</editor-fold>
    
    protected double[] rayDir;
    //<editor-fold defaultstate="collapsed" desc="getDirection">
    public double[] getDirection()
    {
        return this.rayDir;
    }
    //</editor-fold>
    
    public Ray(double[] origin, double[] direction)
    {
        this.rayOrigin = origin;
        
        this.rayDir = direction;
        Vecmath.normalize(direction);
    }
    
    public double[] getPointAt(double t)
    { // point = rayOrigin + t * rayDir
        double[] point = new double[] { this.rayDir[0], this.rayDir[1], this.rayDir[2] };
        Vecmath.scale(point, t);
        Vecmath.translate(point, this.rayOrigin);
        return point;
    }
    
}
